<template>
    <div>
        <el-row :gutter="20">
            <el-col :span="8">
                <el-card shadow="hover" class="mgb20" style="height:202px;">
                    <div class="user-info">
                        <img src="../assets/img/head.jpeg" class="user-avator" alt />
                        <div class="user-info-cont">
                            <div class="user-info-name">{{ username }}</div>
                            <div>{{ roleName }} </div>
                        </div>
                    </div>
                </el-card>
                <el-card shadow="hover" style="height:252px;">
                    <template #header>
                        <div class="clearfix">
                            <span>系统信息</span>
                        </div>
                    </template>
<!--                    Vue-->
<!--                    <el-progress :percentage="71.3" color="#42b983"></el-progress>JavaScript-->
<!--                    <el-progress :percentage="24.1" color="#f1e05a"></el-progress>CSS-->
<!--                    <el-progress :percentage="13.7"></el-progress>HTML-->
<!--                    <el-progress :percentage="5.9" color="#f56c6c"></el-progress>-->

                  <table border style=" border-collapse:collapse; text-align: center" >
                    <tr style="height: 40px">
                      <th style="width: 200px;">项目名称</th>
                      <td style="width: 200px;">核酸检测预约系统</td>
                    </tr>
                    <tr style="height: 40px">
                      <th>主要技术</th>
                      <td>SpringBoot</td>
                    </tr>
                    <tr style="height: 40px">
                      <th>开发者</th>
                      <td>刘彬</td>
                    </tr>
                    <tr style="height: 40px">
                      <th>开发时间</th>
                      <td>3月 - 5月</td>
                    </tr>
                  </table>
                </el-card>
            </el-col>
            <el-col :span="16">
<!--                <el-row :gutter="20" class="mgb20">-->
<!--                    <el-col :span="8">-->
<!--                        <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--                            <div class="grid-content grid-con-1">-->
<!--                                <i class="el-icon-user-solid grid-con-icon"></i>-->
<!--                                <div class="grid-cont-right">-->
<!--                                    <div class="grid-num">1234</div>-->
<!--                                    <div>用户访问量</div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </el-card>-->
<!--                    </el-col>-->
<!--                    <el-col :span="8">-->
<!--                        <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--                            <div class="grid-content grid-con-2">-->
<!--                                <i class="el-icon-message-solid grid-con-icon"></i>-->
<!--                                <div class="grid-cont-right">-->
<!--                                    <div class="grid-num">321</div>-->
<!--                                    <div>系统消息</div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </el-card>-->
<!--                    </el-col>-->
<!--                    <el-col :span="8">-->
<!--                        <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--                            <div class="grid-content grid-con-3">-->
<!--                                <i class="el-icon-s-goods grid-con-icon"></i>-->
<!--                                <div class="grid-cont-right">-->
<!--                                    <div class="grid-num">5000</div>-->
<!--                                    <div>数量</div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </el-card>-->
<!--                    </el-col>-->
<!--                </el-row>-->
                <el-card shadow="hover" style="height:473px;">
                    <template #header>
                        <div class="clearfix">
                            <span>预约状态比例图</span>
                        </div>
                    </template>
                    <el-card shadow="hover">
                      <schart v-if="roleName == '系统管理员'" class="schart" canvasId="pie" :options="options1"></schart>
                      <schart v-else class="schart" canvasId="pie" :options="options11"></schart>
                    </el-card>
                </el-card>
            </el-col>
        </el-row>
        <el-row :gutter="20">
            <el-col :span="12">
                <el-card shadow="hover">
                    <schart v-if="roleName == '系统管理员'" ref="bar" class="schart" canvasId="bar" :options="options2"></schart>
                    <schart v-else ref="bar" class="schart" canvasId="bar" :options="options22"></schart>
                </el-card>
            </el-col>
            <el-col :span="12">
                <el-card shadow="hover">
                    <schart v-if="roleName == '系统管理员'" ref="line" class="schart" canvasId="line" :options="options3"></schart>
                    <schart v-else ref="line" class="schart" canvasId="line" :options="options33"></schart>
                </el-card>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import Schart from "vue-schart";
import order from "../api/order";
export default {
    name: "dashboard",
    components: { Schart },
  data(){
      return{
        hospId:sessionStorage.getItem("hospId"),
        role:sessionStorage.getItem("role"),
        username:sessionStorage.getItem("username"),
        roleName:sessionStorage.getItem("role") == 'superadmin' ? "系统管理员" : "管理员",
        time:JSON.stringify(sessionStorage.getItem("loginTime")),
        options1:{
          type: "pie",
          title: {
            text: "预约状态比例图",
          },
          legend: {
            position: "left",
          },
          bgColor: "#fbfbfb",
          labels: [
            "预约未检",
            "已检未果",
            "已检有果"
          ],
          datasets: [
            {data:[11,29,61]}
          ],
        },
        options11:{
          type: "pie",
          title: {
            text: "预约状态比例图",
          },
          legend: {
            position: "left",
          },
          bgColor: "#fbfbfb",
          labels: [
            "预约未检",
            "已检未果",
            "已检有果"
          ],
          datasets: [
            {data:[3,7,15]}
          ],
        },
        options2:{
          type: "bar",
          title: {
            text: "部分医院阴性及阳性人数",
          },
          labels: ["河南省人民医院", "郑州人民医院", "郑州市第九人民医院", "郑州市金水区总医院"],
          datasets: [
            {
              label: "阴性",
              data: [21, 23, 17, 21],
            },
            {
              label: "阳性",
              data: [5, 2, 8, 4],
            }
          ],
        },
        options22:{
          type: "bar",
          title: {
            text: "医院阴性及阳性人数",
          },
          labels: [ "郑州人民医院"],
          datasets: [
            {
              label: "阴性",
              data: [22],
            },
            {
              label: "阳性",
              data: [3],
            }
          ],
        },

        options3:{
          type: "line",
          title: {
            text: "部分地区阴性及阳性人数",
          },
          xRorate: 25,
          labels: ["中原区", "二七区", "管城区", "金水区"],
          datasets: [
            {
              label: "阴性",
              data: [17, 21, 20, 23],
            },
            {
              label: "阳性",
              data: [8, 4, 5, 2],
            }
          ],
        },
        options33:{
          type: "line",
          title: {
            text: "近一周阴性及阳性人数",
          },
          xRorate: 25,
          labels: ["4-24", "4-25", "4-26", "4-27","4-28","4-29","4-30"],
          datasets: [
            {
              label: "阴性",
              data: [4, 2, 4, 4,1,3,4],
            },
            {
              label: "阳性",
              data: [0, 1, 0, 0,2,0,0],
            }
          ],
        },

      }
  },
  created() {

    this.getOrderStatusCount(0)
  },
  methods:{
    getOrderStatusCount(hospId){
      order.getOrderStatusCount(hospId).then(response=>{
        this.statusList = response.data
        console.log(this.statusList)
      })
    }
  },
    // setup() {
    //     const role = sessionStorage.getItem("role");
    //     const username = sessionStorage.getItem("username")
    //     const roleName = role == "admin" ? "管理员" : "系统管理员";
    //     const time = JSON.stringify(sessionStorage.getItem("loginTime"))
    //     console.log(time)
    //   //   let hospId = sessionStorage.getItem("hospId");
    //   //   if(hospId == 'null'){
    //   //     hospId = 0
    //   //   }
    //   //   const statusList = reactive({
    //   //     list:[]
    //   //   })
    //   //   order.getOrderStatusCount(hospId).then(response=>{
    //   //     statusList.list = response.data
    //   //     console.log("list:"+response.data)
    //   //   })
    //   // // new Schart('canvas3', options1);
    //   //   const options = {
    //   //       type: "bar",
    //   //       title: {
    //   //           text: "最近一周各品类销售图",
    //   //       },
    //   //       xRorate: 25,
    //   //       labels: ["周一", "周二", "周三", "周四", "周五"],
    //   //       datasets: [
    //   //           {
    //   //               label: "家电",
    //   //               data: [234, 278, 270, 190, 230],
    //   //           },
    //   //           {
    //   //               label: "百货",
    //   //               data: [164, 178, 190, 135, 160],
    //   //           },
    //   //           {
    //   //               label: "食品",
    //   //               data: [144, 198, 150, 235, 120],
    //   //           },
    //   //       ],
    //   //   };
    //   //   const options2 = {
    //   //       type: "line",
    //   //       title: {
    //   //           text: "最近几个月各品类销售趋势图",
    //   //       },
    //   //       labels: ["6月", "7月", "8月", "9月", "10月"],
    //   //       datasets: [
    //   //           {
    //   //               label: "家电",
    //   //               data: [234, 278, 270, 190, 230],
    //   //           },
    //   //           {
    //   //               label: "百货",
    //   //               data: [164, 178, 150, 135, 160],
    //   //           },
    //   //           {
    //   //               label: "食品",
    //   //               data: [74, 118, 200, 235, 90],
    //   //           },
    //   //       ],
    //   //   };
    //   //
    //   // const  options1={
    //   //   type: "pie",
    //   //   title: {
    //   //     text: "预约状态比例图",
    //   //   },
    //   //   legend: {
    //   //     position: "left",
    //   //   },
    //   //   bgColor: "#fbfbfb",
    //   //   labels: [
    //   //     "预约未检",
    //   //     "已检未果",
    //   //     "已检有果"
    //   //   ],
    //   //   datasets: [
    //   //     {
    //   //       data: statusList.list
    //   //     },
    //   //   ],
    //   // };
    //
    //     return {
    //         time,
    //         username,
    //         roleName,
    //     };
    // },
};
</script>

<style scoped>
.el-row {
    margin-bottom: 20px;
}

.grid-content {
    display: flex;
    align-items: center;
    height: 100px;
}

.grid-cont-right {
    flex: 1;
    text-align: center;
    font-size: 14px;
    color: #999;
}

.grid-num {
    font-size: 30px;
    font-weight: bold;
}

.grid-con-icon {
    font-size: 50px;
    width: 100px;
    height: 100px;
    text-align: center;
    line-height: 100px;
    color: #fff;
}

.grid-con-1 .grid-con-icon {
    background: rgb(45, 140, 240);
}

.grid-con-1 .grid-num {
    color: rgb(45, 140, 240);
}

.grid-con-2 .grid-con-icon {
    background: rgb(100, 213, 114);
}

.grid-con-2 .grid-num {
    color: rgb(45, 140, 240);
}

.grid-con-3 .grid-con-icon {
    background: rgb(242, 94, 67);
}

.grid-con-3 .grid-num {
    color: rgb(242, 94, 67);
}

.user-info {
    display: flex;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 2px solid #ccc;
    margin-bottom: 20px;
}

.user-avator {
    width: 120px;
    height: 120px;
    border-radius: 50%;
}

.user-info-cont {
    padding-left: 50px;
    flex: 1;
    font-size: 14px;
    color: #999;
}

.user-info-cont div:first-child {
    font-size: 30px;
    color: #222;
}

.user-info-list {
    font-size: 14px;
    color: #999;
    line-height: 25px;
}

.user-info-list span {
    margin-left: 70px;
}

.mgb20 {
    margin-bottom: 20px;
}

.todo-item {
    font-size: 14px;
}

.todo-item-del {
    text-decoration: line-through;
    color: #999;
}

.schart {
    width: 100%;
    height: 300px;
}
</style>
